package sy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * SysOwnerRenterMapping entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sys_owner_renter_mapping", catalog = "ssh")
public class SysOwnerRenterMapping implements java.io.Serializable {

	// Fields

	private String id;
	private SysAccount sysAccountByOwner;
	private SysAccount sysAccountByRenter;
	private String remarks;

	@JsonProperty(value = "sysAccountByOwnerName")
    private String sysAccountByOwnerName;
	
	@JsonProperty(value = "sysAccountByRenterName")
    private String sysAccountByRenterName;

	/** default constructor */
	public SysOwnerRenterMapping() {
	}

	/** full constructor */
	public SysOwnerRenterMapping(SysAccount sysAccountByOwner,
			SysAccount sysAccountByRenter, String remarks) {
		this.sysAccountByOwner = sysAccountByOwner;
		this.sysAccountByRenter = sysAccountByRenter;
		this.remarks = remarks;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "owner")
	public SysAccount getSysAccountByOwner() {
		return this.sysAccountByOwner;
	}

	public void setSysAccountByOwner(SysAccount sysAccountByOwner) {
		this.sysAccountByOwner = sysAccountByOwner;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "renter")
	public SysAccount getSysAccountByRenter() {
		return this.sysAccountByRenter;
	}

	public void setSysAccountByRenter(SysAccount sysAccountByRenter) {
		this.sysAccountByRenter = sysAccountByRenter;
	}

	@Column(name = "remarks")
	public String getRemarks() {
		return this.remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	@Transient
	public String getSysAccountByOwnerName() {
		return getSysAccountByOwner().getName();
	}

	public void setSysAccountByOwnerName(String sysAccountByOwnerName) {
		this.sysAccountByOwnerName = sysAccountByOwnerName;
	}

	@Transient
	public String getSysAccountByRenterName() {
		return getSysAccountByRenter().getName();
	}

	public void setSysAccountByRenterName(String sysAccountByRenterName) {
		this.sysAccountByRenterName = sysAccountByRenterName;
	}
	
	

}